// 创建新的系统信息工具函数
export const getSystemInfo = () => {
  // 添加版本兼容判断
  if (!wx.getWindowInfo || !wx.getDeviceInfo) {
    console.warn('基础库版本过低，使用旧API')
    const systemInfo = wx.getSystemInfoSync()
    return {
      windowWidth: systemInfo.windowWidth,
      windowHeight: systemInfo.windowHeight,
      statusBarHeight: systemInfo.statusBarHeight,
      pixelRatio: systemInfo.pixelRatio,
      brand: systemInfo.brand,
      model: systemInfo.model,
      system: systemInfo.system,
      platform: systemInfo.platform
    }
  }

  try {
    const windowInfo = wx.getWindowInfo()
    const deviceInfo = wx.getDeviceInfo()
    const appBaseInfo = wx.getAppBaseInfo()
    
    return {
      // 窗口信息
      windowWidth: windowInfo.windowWidth,
      windowHeight: windowInfo.windowHeight,
      pixelRatio: windowInfo.pixelRatio,
      // 设备信息
      brand: deviceInfo.brand,
      model: deviceInfo.model,
      system: deviceInfo.system,
      platform: deviceInfo.platform,
      // 状态栏
      statusBarHeight: windowInfo.statusBarHeight,
      // 安全区域
      safeArea: deviceInfo.safeArea,
      // 应用信息
      appTheme: appBaseInfo.theme,
      language: appBaseInfo.language
    }
  } catch(e) {
    console.error('获取系统信息失败:', e)
    return {}
  }
} 